
<%- include ('../public/page_header.html') %>
<div class="">
  <ol class="breadcrumb">
    <li>添加导航</li>
  </ol>
  <form action="/admin/nav/doAdd" method="post" id="form">
    <div class="form-group row">
      <label for="title" class="col-sm-2">导航名称：</label>
      <div class="col-sm-10"><input type="text" class="form-control" name="title" id="title"></div>
    </div>
    <div class="form-group row">
      <label for="link" class="col-sm-2">导航链接地址：</label>
      <div class="col-sm-10"><input type="url" class="form-control" name="link" id="link"></div>
    </div>
    <div class="form-group row">
      <label for="position" class="col-sm-2">导航位置：</label>
      <div class="col-sm-10">
        <select class="form-control" name="position" id="position">
          <option value="1">顶部</option>
          <option value="2" selected>中间</option>
          <option value="3">底部</option>
        </select>
      </div>
    </div>
    <div class="form-group row">
      <label for="open" class="col-sm-2">新窗口打开：</label>
      <div class="col-sm-10">
        <select class="form-control" name="is_opennew" id="open">
          <option value="1">是</option>
          <option value="0">否</option>
        </select>
      </div>
    </div>
    <div class="form-group row">
      <label for="email" class="col-sm-2">排序：</label>
      <div class="col-sm-10"><input type="number" class="form-control" name="sort" id="sort"></div>
    </div>
    <div class="form-group mb-2 row">
      <label class="col-sm-2">状态：</label>
      <div class="form-check" class="col-sm-10">
        <input class="form-check-input" type="radio" name="status" id="exampleRadios1" value="1" checked>
        <label class="form-check-label" for="exampleRadios1">
          显示
        </label>
        &nbsp;&nbsp;&nbsp;
        <input class="form-check-input" type="radio" name="status" id="exampleRadios2" value="0">
        <label class="form-check-label" for="exampleRadios2">
          隐藏
        </label>
      </div>
    </div>
    <div class="form-group row">
      <label class="col-sm-2"></label>
      <div class="col-sm-10">
        <div class="error text-danger"></div>
        <button type="submit" class="btn btn-primary btn-sm">提交</button></div>
    </div>
  </form>
</div>
<script>
  $('#form').submit(function() {
    var title = $('#title').val()
    // var password = $('#password').val()
    // var rpassword = $('#rpassword').val()

    if(title.length === 0) {
      $('.error').html('Error: 导航名称不能为空')
      return false
    }
    // if(password.length < 6 ) {
    //   $('.error').html('Error: 密码长度不能小于6位')
    //   return false
    // }

    // if(password !== rpassword ) {
    //   $('.error').html('Error: 密码和确认密码不一致')
    //   return false
    // }
    if($('.error').html()) {
      $('.error').html('')
    }
    return true
  })
</script>
</body>
</html>